package com.xju.subjectsystem.pojo;

import lombok.Data;

/**
 * -*- coding:utf-8 -*-
 *
 * @projectName: Subjectsystem
 * @package: com.xju.subjectsystem.utils
 * @className: Result
 * @author: Eiard
 * @description: DONE : 自定义封装信息格式
 * @date: 2024-12-04 23:44
 */
@Data
public class Result {

    /**
     * 回显信息格式
     * status   1成功 0失败
     * msg      描述信息
     * data     数据
     */
    private Integer status;
    private String msg;
    private Object data;

    /**
     * @methodName: success
     * @package: com.xju.subjectsystem.utils
     * @description: DONE : 响应成功
     * @author: Eiard
     * @date: 2024-12-04 23:49
     * @return: Result
     */
    public static Result success() {
        Result result = new Result();
        result.status = 1;
        result.msg = "success";
        return result;
    }

    /**
     * @methodName: success
     * @package: com.xju.subjectsystem.utils
     * @description: DONE : 数据自定义相应成功(包含响应数据)
     * @author: Eiard
     * @date: 2024-12-04 23:52
     * @param: object 数据
     * @return: Result
     */
    public static Result success(Object object) {
        Result result = new Result();
        result.data = object;
        result.status = 1;
        result.msg = "success";
        return result;
    }

    /**
     * @methodName: success
     * @package: com.xju.subjectsystem.pojo
     * @description: DONE : 自定义成功反馈信息
     * @author: Eiard
     * @date: 2024-12-07 21:38
     * @param: object   返回数据
     * @param: msg      自定义反馈信息
     * @return: Result
     */
    public static Result success(String msg, Object object) {
        Result result = new Result();
        result.data = object;
        result.status = 1;
        result.msg = msg;
        return result;
    }

    /**
     * @methodName: error
     * @package: com.xju.subjectsystem.utils
     * @description: DONE : 响应失败
     * @author: Eiard
     * @date: 2024-12-04 23:56
     * @param: msg
     * @return: Result
     */
    public static Result error(String msg) {
        Result result = new Result();
        result.status = 0;
        result.msg = msg;
        return result;
    }

    public static Result error(String msg, Object object) {
        Result result = new Result();
        result.data = object;
        result.status = 0;
        result.msg = msg;
        return result;
    }
}
